/*package com.szgd.util;

import java.io.IOException;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.conn.PoolingClientConnectionManager;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import org.apache.commons.httpclient.Cookie;  
import org.apache.commons.httpclient.HttpClient;  
import org.apache.commons.httpclient.NameValuePair;
import org.apache.commons.httpclient.cookie.CookiePolicy;  
import org.apache.commons.httpclient.methods.GetMethod;  
import org.apache.commons.httpclient.methods.PostMethod;  

public class GetSuzData {
	private static String loginUrl = "http://61.155.204.87:8888/login.do?method=loginRisk&t="
			+ Math.random();
	private static String SearchUrl = "http://61.155.204.87:8888/monitorData.do?method=showMonitorData&user_type=1&location_id=230";
	private String charset = "UTF-8";

	public void test() throws IOException, URISyntaxException {
//		// 存放发送参数
//		Map<String, String> createMap = new HashMap<String, String>();
//		createMap.put("name", "chenhaifeng");
//		createMap.put("password", "suzhou123");
//		createMap
//				.put("image",
//						OcrUtil.getCode(HttpUtils
//								.downLoadJpgFromOtherSystem("http://61.155.204.87:8888/jsp/ValidateCodeServlet")));
//		createMap.put("address", "(IP：218.80.193.33；位置：上海市浦东新区)");
//		HttpPost httpPost = null;
//		HttpPost httpPost2 = null;
//		HttpResponse response = null;
//		DefaultHttpClient client = null;
//		String result = null;
//		try {
//			client = new DefaultHttpClient(new PoolingClientConnectionManager());
//			httpPost = new HttpPost(loginUrl);
//			// 设置请求头
//			httpPost.setHeader("User-Agent",
//					"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Firefox/45.0");
//			// 设置参数
//			List<NameValuePair> list = new ArrayList<NameValuePair>();
//			Iterator iterator = createMap.entrySet().iterator();
//			while (iterator.hasNext()) {
//				Entry<String, String> elem = (Entry<String, String>) iterator
//						.next();
//				list.add(new BasicNameValuePair(elem.getKey(), elem.getValue()));
//			}
//			if (list.size() > 0) {
//				UrlEncodedFormEntity entity = new UrlEncodedFormEntity(list,
//						charset);
//				httpPost.setEntity(entity);
//			}
//			// 第一次请求
//			response = client.execute(httpPost);
//			System.out.println(response);
//			// 第二次请求
//			httpPost2 = new HttpPost(SearchUrl);
//			response = client.execute(httpPost2);
//			System.out.println(response);
//			// 登录后的请求内容
//			if (response != null) {
//				HttpEntity resEntity = response.getEntity();
//				if (resEntity != null) {
//					result = EntityUtils.toString(resEntity, charset);
//				}
//			}
//			// System.out.println(result);
//		} catch (Exception ex) {
//			ex.printStackTrace();
//		}
	}

	public static void main(String[] args) throws IOException,
			URISyntaxException {
		// GetSuzData main = new GetSuzData();
		// main.test();

		HttpClient httpClient = new HttpClient();

		// 模拟登陆，按实际服务器端要求选用 Post 或 Get 请求方式
		PostMethod postMethod = new PostMethod(loginUrl);

		// 设置登陆时要求的信息，用户名和密码
		NameValuePair[] data = { new NameValuePair("name", "chenhaifeng"),
				new NameValuePair("password", "suzhou123"),
				new NameValuePair("image", OcrUtil.getCode(HttpUtils
						.downLoadJpgFromOtherSystem("http://61.155.204.87:8888/jsp/ValidateCodeServlet"))),
				new NameValuePair("address", "(IP：218.80.193.33；位置：上海市浦东新区)")};
		postMethod.setRequestBody(data);
		try {
			// 设置 HttpClient 接收 Cookie,用与浏览器一样的策略
			httpClient.getParams().setCookiePolicy(
					CookiePolicy.BROWSER_COMPATIBILITY);
			httpClient.executeMethod(postMethod);
			// 获得登陆后的 Cookie
			Cookie[] cookies = httpClient.getState().getCookies();
			StringBuffer tmpcookies = new StringBuffer();
			for (Cookie c : cookies) {
				tmpcookies.append(c.toString() + ";");
			}
			// 进行登陆后的操作1581,1602,1603,1610,1609,1608,1607,1606,1605,1620,1619,1617,1616,1622,1626,1642,1648,1647,1657
//			GetMethod getMethod = new GetMethod("http://61.155.204.87:8888/pages/workbench.jsp?page_flag=1");
			GetMethod getMethod = new GetMethod(SearchUrl);
			// 每次访问需授权的网址时需带上前面的 cookie 作为通行证
			getMethod.setRequestHeader("cookie", tmpcookies.toString());
			// 你还可以通过 PostMethod/GetMethod 设置更多的请求后数据
			// 例如，referer 从哪里来的，UA 像搜索引擎都会表名自己是谁，无良搜索引擎除外
			getMethod.setRequestHeader("Referer", "http://www.cc");
			getMethod.setRequestHeader("User-Agent", "www Spot");
			httpClient.executeMethod(getMethod);
			// 打印出返回数据，检验一下是否成功
			String text = getMethod.getResponseBodyAsString();
			System.out.println(text);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
*/